<?php
	session_start();
	require_once('functions.php');
	
	if( $_SESSION['account_type_code'] != 1) 
	{
		header("Location:index.php?response_msg=Please login.");
		exit;
	}
	
	$boatname = $_POST['boat_name'];
	$boatcolor = $_POST['boat_color'];

	if(!$boatname || !$boatcolor )
	{	
		$error_msg = "Please fill in all the values.";
	}
	
	
	if($error_msg)
	{
		header("Location:admin.php?response_msg=".$error_msg);
		exit;
	}
	else
	{
		$new_boat = add_new_boat($boatname, $boatcolor);
		if( $new_boat )
		{
			header("Location:admin.php?response_msg=New boat added with ID:".htmlspecialchars($new_boat) );
			exit;
		}
		else
		{
			header("Location:admin.php?response_msg=An error has occurred. New boat could not be added.");
			exit;
		}
	}
?>